#pragma once

namespace Json
{

template <typename T>
class Reference
{
public:
	Reference() : m_p(0) {}

	const T* operator -> () const {return (T*) m_p;}
	operator T* () const {return m_p;}
	void SetReference(const T* p) {m_p = p;}
	const char* GetLocation() const {return m_ref.c_str();}

	template <typename Archive, typename U> friend void Serialise(Archive& ar, Reference<U>& t);

private:
	const T* m_p;
	std::string m_ref;
};

template <typename Archive, typename T> 
void Serialise(Archive& ar, Reference<T>& t)
{
	ar.SerialiseString(t.m_ref);
}

}

namespace Serialisation
{

template <typename T>
struct SerialisationInfo <Json::Reference<T>>
{
	const static SerialisationType type = SerialisationType::String;
};

}